package at.guigu.service;

import at.guigu.exception.MyException;
import org.springframework.stereotype.Service;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

@Service
public class UserService {
    public void show1() {
        System.out.println("抛出类型转换异常");
        Object str = "zhangsan";
        Integer num = (Integer) str;
    }
    public void show2() {
        System.out.println("抛出除0异常");
        int i = 1/0;
    }
    public void show3() throws FileNotFoundException {
        System.out.println("抛出文件找不到异常");
        InputStream inputStream = new FileInputStream("C:/xxx/xxx/xxx.txt");
    }
    public void show4() {
        System.out.println("抛出空指针异常");
        String str = null;
        str.length();
    }
    public void show5() throws MyException {
        System.out.println("抛出自定义异常");
        throw new MyException();
    }
}
